import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

public class Java011 {
        public static void main(String[] args){

            ArrayList<student> students = new ArrayList<student>();
            addStudentName(students);
            printStudentsName(students);
            String randName=randStudentName(students);
            System.out.println("幸运儿"+randName);
        }

        public static void addStudentName(ArrayList<student> students){
            Scanner sc=new Scanner(System.in);
            for(int i=0;i<3;i++){
                student s = new student();
                System.out.println("存储第"+(i+1)+"个名称");
                s.id=i+1;
                System.out.println("name");
                s.name=sc.next();
                System.out.println("age");
                s.age = sc.nextInt();
                students.add(s);
            }

        }
        private static void printStudentsName(ArrayList<student> students) {
            for(int i=0;i<students.size();i++){
                student s = students.get(i);
                System.out.println("第"+(i+1)+"个学生id："+s.id);
                System.out.println("第"+(i+1)+"个学生age："+s.age);
                System.out.println("第"+(i+1)+"个学生名称："+s.name);
            }

        }
        public static String randStudentName(ArrayList<student> students){
            Random random = new Random();
            int index=random.nextInt(students.size());
            student s = students.get(index);
            return s.name;
        }


}
//改抽学生